package com.luocj.refresh.activity;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.luocj.refresh.R;
import com.luocj.refresh.model.MultiModel;
import com.luocj.refresh.adapter.MultiItemAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import java.util.ArrayList;

public class MultiItemActicity extends AppCompatActivity {

    private SmartRefreshLayout refreshlayout;
    private RecyclerView recyclerview;
    private Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_item_acticity);
        mContext = this;
        initData();
        initView();
    }

    private ArrayList<MultiModel> initData() {
        ArrayList<MultiModel> multiModels = new ArrayList<>();
        for (int i = 0; i < 30; i++) {
            multiModels.add(new MultiModel("title:" + i, "content:" + i, (int) (Math.random() * 3), (int) (Math.random() * 2)));
        }
        return multiModels;
    }

    private void initView() {
        refreshlayout = findViewById(R.id.smartrefreshlayout_multi_item);
        recyclerview = findViewById(R.id.recyclerview_multi_item);
        recyclerview.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        MultiItemAdapter adapter = new MultiItemAdapter(mContext, initData());
        recyclerview.setAdapter(adapter);
    }
}
